package cn.zl.model;

import cn.yunbamboos.Model;
import cn.yunbamboos.mybatis.annotation.TableField;
import cn.yunbamboos.mybatis.annotation.TableName;
import cn.yunbamboos.mybatis.annotation.TablePrimaryKey;
import cn.yunbamboos.rest.service.anno.param.ParamType;
import cn.yunbamboos.rest.service.anno.param.enums.Type;
import com.alibaba.fastjson2.JSONObject;

@TableName(value = "zl_virtual_video_stream", cn = "模拟视频流表")
public class VirtualVideoStream implements Model {

    @ParamType(path = "file_id", type = Type.Long, title = "文件ID", required = true, example = "1")
    @TablePrimaryKey(value = "file_id")
    private String fileId;
    @ParamType(path = "file_type", type = Type.String, title = "文件类型", required = true, example = "mp4")
    @TableField(value = "file_type")
    private String fileType;
    @ParamType(path = "app", type = Type.String, title = "流的应用名", required = true, example = "virtual-video-stream")
    @TableField(value = "app")
    private String app;
    @ParamType(path = "stream", type = Type.String, title = "流的名称", required = true, example = "test")
    @TableField(value = "stream")
    private String stream;
    @ParamType(path = "state", type = Type.Integer, title = "状态", required = true, example = "1", description = "0未开启,1开启")
    @TableField(value = "state")
    private int state;
    @ParamType(path = "create_time", type = Type.String, title = "创建时间", required = true, example = "2024-01-01 00:00:00")
    @TableField(value = "create_time")
    private String createTime;

    @Override
    public JSONObject encode() {
        JSONObject json = new JSONObject();
        json.put("file_id", fileId);
        json.put("file_type", fileType);
        json.put("app", app);
        json.put("stream", stream);
        json.put("create_time", createTime);
        json.put("state", state);
        return json;
    }

    @Override
    public void decode(JSONObject json) {
        if (json.containsKey("file_id")) this.fileId = json.getString("file_id");
        if (json.containsKey("app")) this.app = json.getString("app");
        if (json.containsKey("stream")) this.stream = json.getString("stream");
        if (json.containsKey("state")) this.state = json.getInteger("state");
        if (json.containsKey("create_time")) {
            this.createTime = json.getString("create_time");
        }
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public String getApp() {
        return app;
    }

    public void setApp(String app) {
        this.app = app;
    }

    public String getStream() {
        return stream;
    }

    public void setStream(String stream) {
        this.stream = stream;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }


}
